/**
 */
package OBSL.impl;

import OBSL.ModeCharacterizationLink;
import OBSL.ModeIndividual;
import OBSL.OBSLPackage;
import OBSL.PresentIndividual;

import RefOntoUML.Characterization;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mode Characterization Link</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.ModeCharacterizationLinkImpl#getCharacterization <em>Characterization</em>}</li>
 *   <li>{@link OBSL.impl.ModeCharacterizationLinkImpl#getMode <em>Mode</em>}</li>
 *   <li>{@link OBSL.impl.ModeCharacterizationLinkImpl#getBearer <em>Bearer</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ModeCharacterizationLinkImpl extends MinimalEObjectImpl.Container implements ModeCharacterizationLink {
	/**
	 * The cached value of the '{@link #getCharacterization() <em>Characterization</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCharacterization()
	 * @generated
	 * @ordered
	 */
	protected Characterization characterization;

	/**
	 * The cached value of the '{@link #getBearer() <em>Bearer</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBearer()
	 * @generated
	 * @ordered
	 */
	protected PresentIndividual bearer;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModeCharacterizationLinkImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.MODE_CHARACTERIZATION_LINK;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Characterization getCharacterization() {
		if (characterization != null && characterization.eIsProxy()) {
			InternalEObject oldCharacterization = (InternalEObject)characterization;
			characterization = (Characterization)eResolveProxy(oldCharacterization);
			if (characterization != oldCharacterization) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.MODE_CHARACTERIZATION_LINK__CHARACTERIZATION, oldCharacterization, characterization));
			}
		}
		return characterization;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Characterization basicGetCharacterization() {
		return characterization;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCharacterization(Characterization newCharacterization) {
		Characterization oldCharacterization = characterization;
		characterization = newCharacterization;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_CHARACTERIZATION_LINK__CHARACTERIZATION, oldCharacterization, characterization));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ModeIndividual getMode() {
		if (eContainerFeatureID() != OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE) return null;
		return (ModeIndividual)eInternalContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMode(ModeIndividual newMode, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newMode, OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMode(ModeIndividual newMode) {
		if (newMode != eInternalContainer() || (eContainerFeatureID() != OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE && newMode != null)) {
			if (EcoreUtil.isAncestor(this, newMode))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newMode != null)
				msgs = ((InternalEObject)newMode).eInverseAdd(this, OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES, ModeIndividual.class, msgs);
			msgs = basicSetMode(newMode, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE, newMode, newMode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresentIndividual getBearer() {
		if (bearer != null && bearer.eIsProxy()) {
			InternalEObject oldBearer = (InternalEObject)bearer;
			bearer = (PresentIndividual)eResolveProxy(oldBearer);
			if (bearer != oldBearer) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.MODE_CHARACTERIZATION_LINK__BEARER, oldBearer, bearer));
			}
		}
		return bearer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresentIndividual basicGetBearer() {
		return bearer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBearer(PresentIndividual newBearer) {
		PresentIndividual oldBearer = bearer;
		bearer = newBearer;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_CHARACTERIZATION_LINK__BEARER, oldBearer, bearer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetMode((ModeIndividual)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				return basicSetMode(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				return eInternalContainer().eInverseRemove(this, OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES, ModeIndividual.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__CHARACTERIZATION:
				if (resolve) return getCharacterization();
				return basicGetCharacterization();
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				return getMode();
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__BEARER:
				if (resolve) return getBearer();
				return basicGetBearer();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__CHARACTERIZATION:
				setCharacterization((Characterization)newValue);
				return;
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				setMode((ModeIndividual)newValue);
				return;
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__BEARER:
				setBearer((PresentIndividual)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__CHARACTERIZATION:
				setCharacterization((Characterization)null);
				return;
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				setMode((ModeIndividual)null);
				return;
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__BEARER:
				setBearer((PresentIndividual)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__CHARACTERIZATION:
				return characterization != null;
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE:
				return getMode() != null;
			case OBSLPackage.MODE_CHARACTERIZATION_LINK__BEARER:
				return bearer != null;
		}
		return super.eIsSet(featureID);
	}

} //ModeCharacterizationLinkImpl
